package rozetka.utils;

/**
 * Created by foneox on 05.04.2014.
 */
public class User {
    private static final int RANDOM_STRING_LENGTH = 10;
    private String userName;
    private String userEmail;
    private String userPassword;

    public User(String userName, String userEmail, String userPassword) {
        this.userName = userName;
        this.userEmail = userEmail;
        this.userPassword = userPassword;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserEmail() {
        return userEmail;
    }

    public void setUserEmail(String userEmail) {
        this.userEmail = userEmail;
    }

    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

    public static User generateRandomUser(String emailPrefix, String emailDomainName, String password) {
        String randomSting = RandomStringGenerator.getRandomString(RANDOM_STRING_LENGTH);
        String randomUserName = String.format("%s%s", emailPrefix, randomSting);
        String randomUserEmail = String.format("%s@%s", randomUserName, emailDomainName);
        String userPassword = password;
        ReportWriter.info(String.format("User %s was randomly generated", randomUserEmail));
        return new User(randomUserName, randomUserEmail.toLowerCase(), userPassword);
    }
}
